#include "Util.h"
#include "iconv/iconv.h" 
#pragma comment(lib,"libiconv.lib")  

bool Util::Gbk2Utf8(std::string &gbkStr)
{
	iconv_t iconvH;
	iconvH = iconv_open("utf-8", "gb2312");
	if (iconvH == 0){
		return false;
	}
	const char* strChar = gbkStr.c_str();
	const char** pin = &strChar;
	size_t strLength = gbkStr.length();
	char* outbuf = (char*)malloc(strLength * 4);
	char* pBuff = outbuf;
	memset(outbuf, 0, strLength * 4);
	size_t outLength = strLength * 4;
	if (-1 == iconv(iconvH, pin, &strLength, &outbuf, &outLength)){
		iconv_close(iconvH);
		return false;
	}
	gbkStr = pBuff;
	iconv_close(iconvH);
	return true;
}

